package com.linkdood.app.schedule;

import com.linkdood.app.service.MessageScannerService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * 消息扫描定时任务
 *
 * @author huangshuo
 */
@Slf4j
@Component
public class MessageScannerTask extends QuartzJobBean {

    /**
     * 此处必须要使用 Autowired 或者 Setter， 不可以使用构造器
     */
    @Autowired
    private MessageScannerService messageScannerService;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) {
        try {
            log.debug("Ddio message scan start ...");
            messageScannerService.scanTemplateMessage();
            log.debug("Ddio message scan end ...");
        } catch (Exception e) {
            log.error("Message scan task error : {}", e.getMessage());
        }
    }

}
